package com.ruoyi.project.king.strongequip.controller;

import java.util.List;

import com.ruoyi.project.king.strongequip.domain.TStrongequip;
import com.ruoyi.project.king.strongequip.service.ITStrongequipService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 硬装详情Controller
 * 
 * @author ruoyi
 * @date 2020-05-21
 */
@Controller
@RequestMapping("/system/strongequip")
public class TStrongequipController extends BaseController
{
    private String prefix = "cms/strongequip";

    @Autowired
    private ITStrongequipService tStrongequipService;

    @RequiresPermissions("system:strongequip:view")
    @GetMapping()
    public String strongequip()
    {
        return prefix + "/strongequip";
    }

    /**
     * 查询硬装详情列表
     */
    @RequiresPermissions("system:strongequip:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TStrongequip tStrongequip)
    {
        startPage();
        List<TStrongequip> list = tStrongequipService.selectTStrongequipList(tStrongequip);
        return getDataTable(list);
    }

    /**
     * 导出硬装详情列表
     */
    @RequiresPermissions("system:strongequip:export")
    @Log(title = "硬装详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TStrongequip tStrongequip)
    {
        List<TStrongequip> list = tStrongequipService.selectTStrongequipList(tStrongequip);
        ExcelUtil<TStrongequip> util = new ExcelUtil<TStrongequip>(TStrongequip.class);
        return util.exportExcel(list, "strongequip");
    }

    /**
     * 新增硬装详情
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存硬装详情
     */
    @RequiresPermissions("system:strongequip:add")
    @Log(title = "硬装详情", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TStrongequip tStrongequip)
    {
        return toAjax(tStrongequipService.insertTStrongequip(tStrongequip));
    }

    /**
     * 修改硬装详情
     */
    @GetMapping("/edit/{tid}")
    public String edit(@PathVariable("tid") Long tid, ModelMap mmap)
    {
        TStrongequip tStrongequip = tStrongequipService.selectTStrongequipById(tid);
        mmap.put("tStrongequip", tStrongequip);
        return prefix + "/edit";
    }

    /**
     * 修改保存硬装详情
     */
    @RequiresPermissions("system:strongequip:edit")
    @Log(title = "硬装详情", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TStrongequip tStrongequip)
    {
        return toAjax(tStrongequipService.updateTStrongequip(tStrongequip));
    }

    /**
     * 删除硬装详情
     */
    @RequiresPermissions("system:strongequip:remove")
    @Log(title = "硬装详情", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tStrongequipService.deleteTStrongequipByIds(ids));
    }
}
